package main

import (
	"code.google.com/p/goblinite/lib"
	"fmt"
	"io"
	"os"
)

const command = "cat"

func usage() {
	fmt.Fprint(os.Stderr, "usage: ", command, " file ...\n")
	os.Exit(2)
}

func main() {

	if len(os.Args) == 1 {
		if _, err := io.Copy(os.Stdout, os.Stdin); err != nil {
			lib.Fatal(command, err)
		}
	} else {
		for _, filename := range os.Args[1:] {
			if src, err := os.Open(filename); err == nil {
				if _, err := io.Copy(os.Stdout, src); err != nil {
					src.Close()
					lib.Fatal(command, err)
				}
				src.Close()
			} else {
				lib.Fatal(command, err)
			}
		}
	}
	os.Exit(0)
}
